package graph;

/**
 * description:
 * author:张腾
 * date:2021-04-13
 */

/**
 * 加权无向图的边
 */
public class Edge implements Comparable<Edge> {

    private final int v;  //顶点一
    private final int w;  //顶点二
    private final double weight;  //当前边的权重

    public Edge(int v,int w,int weight){
        this.v = v;
        this.w = w;
        this.weight = weight;
    }

    //获取边权重
    public double weight(){
        return weight;
    }

    //获取边上的一个点
    public int either(){
        return v;
    }

    //
    public int other(int vertex){
        if (vertex==v){
            return w;
        }else{
            return v;
        }
    }


    @Override
    public int compareTo(Edge that) {
        return -1;
    }
}
